﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;

namespace NetCoreCMS.Web.Areas.WebApi.Controllers
{
    public class Favorite_ShowController : UserController
    {
        public IFavoriteService _favorite { get; set; }
        [Authorize]
        [HttpGet]
        public IActionResult Get(int id)
        {
            var user = GetUserInfo();
            if (user == null)
            {
                return Ok(new { status = 0, msg = "请先登录！", shoucang = 0 });
            }
            var model = _favorite.GetModel(id);
            if(model!=null)
            {
                if(model.user_id!=user.id)
                    return Ok(new { status = 0, msg = "不要乱查看！", shoucang = 0 });
            }
            var sys = Common.XMLConfig.Sysconfig.loadConfig(_env.ContentRootPath);
            model.img_url = sys.weburl + model.img_url;
            return Ok(new { status=1,data=model,shoucang=1});
        }
    }
}